﻿
using UnityEngine;

namespace WooEngine.Utility.Logger
{

    public enum LogLevelEnum
    {
        NO = 0,
        LOG = 1,
        INFO = 2,
        WARN = 3,
        EXCEPT = 4,
        ERROR = 5
    }

    public class WooLogger
    {
        public static LogLevelEnum LogLevel = LogLevelEnum.LOG;

        public static void LogAppendString(params object[] strs)
        {
            Log(StringUtils.AppendString(strs));
        }

        public static void Log(object str)
        {
            if (LogLevel > LogLevelEnum.LOG)
                return;
#if UNITY_EDITOR
            Debug.Log(str);
#elif THRSDKDEBUG
        ThrSDKDebugManager.PrintLog(LogLevel, str.ToString());
#else
        Debug.Log(str); 
#endif
        }

        public static void InfoAppendString(params object[] strs)
        {
            Info(StringUtils.AppendString(strs));
        }

        public static void Info(object str)
        {
            if (LogLevel > LogLevelEnum.INFO)
                return;
#if UNITY_EDITOR
            Debug.Log(str);
#elif THRSDKDEBUG
        ThrSDKDebugManager.PrintLog(LogLevel, str.ToString());
        Debug.Log(str);
#endif
        }

        public static void ErrorAppendString(params object[] strs)
        {
            Error(StringUtils.AppendString(strs));
        }

        public static void Error(object message)
        {
            if (LogLevel > LogLevelEnum.ERROR)
                return;
#if UNITY_EDITOR
            Debug.LogError(message);
#elif THRSDKDEBUG
        ThrSDKDebugManager.PrintLog(LogLevel, message.ToString());
        Debug.LogError(message);
#endif
        }

        public static void WarnAppendString(params object[] strs)
        {
            Warn(StringUtils.AppendString(strs));
        }

        public static void Warn(object message)
        {
            if (LogLevel > LogLevelEnum.WARN)
                return;
#if UNITY_EDITOR
            Debug.LogWarning(message);
#elif THRSDKDEBUG
        ThrSDKDebugManager.PrintLog(LogLevel, message.ToString());
#else
        Debug.LogWarning(message);
#endif
        }

        public static void LogException(System.Exception exception)
        {
            if (LogLevel > LogLevelEnum.EXCEPT)
                return;
#if UNITY_EDITOR
            Debug.LogException(exception);
#elif THRSDKDEBUG
        ThrSDKDebugManager.PrintLog(LogLevel, exception.Message);
#else
        Debug.LogException(exception);
#endif
        }
    }
}